<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 10] Accessing the Environment</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 16:19:21 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch09_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 10</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch10_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="JFC-CH-10">10. Accessing the Environment</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
I/O<br>
<A HREF="ch10_02.htm">System Properties</A><BR>
<A HREF="ch10_03.htm">Environment Variables</A><BR>
<A HREF="ch10_04.htm">External Program Execution</A><BR>
<A HREF="ch10_05.htm">Garbage Collection</A><BR>
<A HREF="ch10_06.htm">Self Termination</A><BR>

<p>
</DIV>

<P CLASS=para>
The <tt CLASS=literal>java.lang.System</tt> and
<tt CLASS=literal>java.lang.Runtime</tt> classes provide a variety of
methods that allow a Java program to access information and resources
for the environment in which it is running. This environment includes
the Java virtual machine and the native operating system.

<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JFC-CH-10-SECT-1">10.1 I/O</A></h2>

<P CLASS=para>
The <tt CLASS=literal>System</tt> class defines three 
<tt CLASS=literal>static</tt> variables for the three 
default I/O stream objects that are used by Java programs: 

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>in</tt><br>
<DD>

<P CLASS=para>
This variable refers to an <tt CLASS=literal>InputStream</tt> 
that is associated with the process's standard input. 

<p>
<DT CLASS=varlistentry><tt CLASS=literal>out</tt><br>
<DD>

<P CLASS=para>
This variable refers to a <tt CLASS=literal>PrintStream</tt> 
object that is associated with the process's standard output. In an 
applet environment, the <tt CLASS=literal>PrintStream</tt> 
is likely to be associated with a separate window or a file, although this 
is not guaranteed.

<P CLASS=para>
This stream is the most commonly used of the three I/O streams provided 
by the <tt CLASS=literal>System</tt> class. Even in 
GUI-based applications, sending output to this stream can be useful for 
debugging purposes. The usual idiom for sending output to this stream is: 
<DIV CLASS=screen>
<P>
<PRE>
System.out.println("some string");
</PRE>
</DIV>


<p>
<DT CLASS=varlistentry><tt CLASS=literal>err</tt><br>
<DD>

<P CLASS=para>
This variable refers to a <tt CLASS=literal>PrintStream</tt> 
object that is associated with the process's standard error output. 
In an applet environment, the <tt CLASS=literal>PrintStream</tt> 
is likely to be associated with a separate window or a file, although this 
is not guaranteed. </DL>
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch09_02.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch10_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>ClassLoader</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>System Properties</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
